/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Review.test3;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author THIEN
 */
public class ThreadTwo extends MyThread {

    public ThreadTwo(Data d) {
        super(d);
    }

    @Override
    public void run() {
        this.displayData();
    }

    public void displayData() {
        int i = 0;
        while(i <3){
            synchronized(this.d){
                if(d.flag){
                    System.out.println(d.temp);
                    d.flag = false;
                    d.notify();
                }
                try {
                    d.wait();
                } catch (InterruptedException ex) {
                    Logger.getLogger(ThreadTwo.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            i++;
        }
    }
}
